SETUPLEN   = 4

BOOTSEG    = 0x7C0

INITSEG    = 0x9000

SETUPSEG   = 0x9020

SYSSEG     = 0x1000

ENDSEG     = SYSYSEG + SYSSIZE

ROOT_DEV   = 0x000

.code16
.text

.global _start
_start:

    jmpl $BOOTSEG, $start2
 
start2:                  # 将bootsect移到0x90000（INITSEG）
    movw $BOOTSEG, %ax  
    movw %ax, %ds
    movw $INITSEG, %ax
    movw %ax, %es
    movw $256, %cx
    subw %si, %si
    subw %di, %di

    rep
    movsw

    jmpl $INITSEG, $go

go:
    movw %cs, %ax
    movw %ax, %ds
    movw %ax, %es
    movw %ax, %ss
    movw $0xFF00, %sp
    
load_setup:
    movw $0x0000, %dx
    movw $0x0002, %cx
    movw $0x0200, %bx
    movb $SETUPLEN, %al
    movb $0x02, %ah
    int $0x13
    jnc ok_load_setup
    movw $0x0000, %dx
    movw $0x0000, %ax
    int $0x13
    jmp load_setup

ok_load_setup:

    movw $msg, %ax
    movw %ax, %bp
    movw $0x01301, %ax
    movw $0x0c, %bx
    movw $21, %cx
    movb $0, %dl
    int  $0x010

    jmpl $SETUPSEG, $0

msg:
    .ascii "Setup has been loaded"

.org 508
root_dev:
    .word ROOT_DEV
boot_flag:
    .word 0x55aa

#.code16
#.text
#.globl _start_setup

#_start_setup:
#    movw %cs, %ax
#    movw %ax, %ds
#    movw %ax, %es

#    movw $setup_msg, %ax
#    movw %ax, %bp
#    movw $0x01301, %ax
#    movw $0x0c, %bx
#    movw $16, %cx
#    movb $3, %dh
#    movb $0, %dl
#    int  $0x010  #中断，向屏幕打印一行信息
 
#setup_msg:
#    .ascii "setup is running"


